package project.ia04.agents.staff;

import jade.domain.DFService;
import jade.domain.FIPAException;
import jade.domain.FIPAAgentManagement.DFAgentDescription;
import jade.domain.FIPAAgentManagement.ServiceDescription;

import java.util.Random;

public class CoderAgent extends StaffAgent {

	@Override
	public String getClassAgent() {
		return "Codeur";
	}

	@Override
	public void setup() {
		super.agentClass = getClassAgent();
		initializeLvl();
		register();
		this.addBehaviour(new StaffListener());
	}

	@Override
	protected void initializeLvl() {
		this.name = this.getLocalName();
		final Random random = new Random();
		this.lvlCoder += random.nextInt(6) + 15; // competance principale
		this.lvlGraphism += random.nextInt(6) + 10; // competance secondaire
		this.lvlCreativity += random.nextInt(6) + 5;
		this.lvlSound += random.nextInt(6);
	}

	private void register() {
		final DFAgentDescription dfd = new DFAgentDescription();
		final ServiceDescription sd = new ServiceDescription();
		sd.setType("StaffAgent");
		sd.setName(this.name);
		dfd.addServices(sd);
		try {
			DFService.register(this, dfd);
		} catch (final FIPAException e) {
			e.printStackTrace();
		}
	}

}
